package cn.czu.wyw.Filter;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @ClassName TestFIlter
 * @Description
 * @Author wyw
 * @Date 2022/12/16 10:11
 * @Version 1.0
 */
@WebFilter(filterName = "testFilter",urlPatterns = "/*")
@Slf4j
public class TestFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        log.info("TestFilter 初始化成功");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        String uri = request.getRequestURI();
        log.info("TestFilter start， uri 为{}",uri);
    }

    @Override
    public void destroy() {

    }
}
